#pragma once
#include "../ComPtrEx.h"
#include "../SevenZip/SevenZipArchiveItem.h"

struct CSevenZipFolder;

struct CSevenZipEnumIDList : CComObjectRootEx<CComSingleThreadModel>,
                             IEnumIDList
{
	DECLARE_NO_REGISTRY()
	DECLARE_NOT_AGGREGATABLE(CSevenZipEnumIDList)

	BEGIN_COM_MAP(CSevenZipEnumIDList)
		COM_INTERFACE_ENTRY(IEnumIDList)
	END_COM_MAP()

	IFACEMETHODIMP Next(__in                               ULONG           Count,
		                __out_ecount_part(Count, *Fetched) PITEMID_CHILD * Result,
                        __out_range(0, Count) 
						__exceptthat __maybenull           ULONG *         Fetched);
    
    IFACEMETHODIMP Skip(ULONG);
        
	IFACEMETHODIMP Reset();
        
    IFACEMETHODIMP Clone(__deref_out_opt IEnumIDList **);

	STDMETHODIMP Initialize(__in CComPtrEx<CSevenZipFolder> &,
	                        __in SevenZip::CSevenZipArchiveItem *,
							     SHCONTF);

private:

	STDMETHODIMP StartEnumeration();

	size_t  _Position;
	SHCONTF _Flags;

	BOOL _Started;

	CComPtrEx<CSevenZipFolder> _Owner;
	CAtlArray<UINT32>  _ItemIndices;

	SevenZip::CSevenZipArchiveItem * _Folder;
};